package com.hongkzh.www.look.enterprise.userinfo.presenter;


import android.util.Log;

import com.hongkzh.www.look.enterprise.userinfo.model.bean.MediaPhotoBean;
import com.hongkzh.www.other.okhttp.CallBackUtil;
import com.hongkzh.www.other.okhttp.OkhttpUtil;
import com.hongkzh.www.look.enterprise.userinfo.view.iview.MediaPhotoIView;
import com.hongkzh.www.presenter.BasePresenter;

import okhttp3.Call;

import static com.hongkzh.www.other.api.Api.GETALLALBUMBYUSERID;


/**
 * 获取 自媒体图集的Presenter
 * Created by as on 2018/3/31.
 */

public class MediaPhotoPresenter extends BasePresenter<MediaPhotoIView> {


    private  boolean isLastPage;

    @Override
    public void attachView(MediaPhotoIView iView) {
        super.attachView(iView);
    }




    // 获取自媒体图集列表数据
    public void GetMediaPhotos(String uid,String pageNumber,String sortId,String sortValue){

        String url= GETALLALBUMBYUSERID(uid,pageNumber,sortId,sortValue);
        Log.i("请求的相册图集的url*****",url);

        OkhttpUtil.okHttpPost(url, new CallBackUtil<MediaPhotoBean>() {
            @Override
            public void onFailure(Call call, Exception e) {

            }

            @Override
            public void onResponse(MediaPhotoBean response) {

//                Log.i("请求图集返回的结果是============",response.getData().toString());
                isLastPage=response.getData().isLastPage();
                if(isLastPage)
                    getIView().onLastPage(isLastPage);
                getIView().onShowMediaPhotoList(response);
            }


        });

    }


    @Override
    public MediaPhotoIView getIView() {
        return super.getIView();
    }

    @Override
    public void detachView() {
        super.detachView();
    }
}
